<?php

class Core_Component_Cms_Method_Template{
    
    function cmsCategorySelectHelper($tmpl, $id, $name) {
        $categories = App::getModel('cms/category')
                        ->getQuery()
                        ->condition('v.website_id', App::getRunningWebsite()->getId())
                        ->fetch()
                        ->toArray();
        return $tmpl->treeSelect($id, $name)
                    ->setOption($tmpl->__('system.label.default_option'), '')
                    ->bindData($categories, 0, array('labelKey'=>'name', 'valueKey'=>'id', 'parentKey'=>'parent_id', 'childKey'=>'id'));
    }
}
